home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / mint / mntdoc01.zoo / mintdoc / pure_src / lib3.src < prev    next >
Encoding:
C/C++ Source or Header  |  1993-03-03  |  62.3 KB  |  1,855 lines

  1. screen( capsensitive("a64l"),
  2.         capsensitive("l64a"))
  3. NAME
  4.     a64l, l64a - convert between long integer and base-64 ASCII string
  5.  
  6. SYNOPSIS
  7.     #include <support.h>
  8.  
  9.     long a64l(const char *s);
  10.  
  11.     char *l64a(long l);
  12.  
  13. DESCRIPTION
  14.     These functions are used to maintain numbers stored in base-64
  15.     ASCII characters. This is a notation by which long integers
  16.     can be represented by up to six characters; each character
  17.     represents a "digit" in a radix-64 notation.
  18.  
  19.     The characters used to represent "digits" are . for 0, / for 1,
  20.     0 through 9 for 2-11, A through Z for 12-37, and a through z
  21.     for 38-63.
  22.  
  23.     a64l takes a pointer to a null-terminated base-64 representation
  24.     and returns a corresponding long value. If the string pointed to
  25.     by s contains more than six characters, a64l will use the first
  26.     six. a64l scans the character string from left to right, decoding
  27.     each character as a 6 bit radix-64 number. If the string contains
  28.     illegal characters, -1 is returned and errno is set to EBADARG.
  29.  
  30.     l64a takes a long argument and returns a pointer to the
  31.     corresponding base-64 representation. If the argument is 0, a64l
  32.     returns a pointer to a null string. If the argument is smaller
  33.     than zero, a pointer to a null string is returned and errno is
  34.     set to EBADARG.
  35.  
  36. CAVEATS
  37.     The value returned by l64a is a pointer into a static buffer,
  38.     the contents of which are overwritten by each call.
  39.  
  40.     The value returned by a64l may be incorrect if the value
  41.     is too large; for that reason, only strings that resulted
  42.     from a call to l64a should be used to call a64l.
  43.  
  44.     Maybe these calls should use unsigned long values, but longs
  45.     are used here to retain compatibility with UN*X System V.\end
  46.  
  47. screen( capsensitive("abort"))
  48. NAME
  49.     abort - abort the current program
  50.  
  51. SYNOPSIS
  52.     #include <stdlib.h>
  53.  
  54.     void abort(void);
  55.  
  56. DESCRIPTION
  57.     abort does the work of \#exit\#, but instead of just exiting, abort
  58.     causes SIGABRT to be sent to the calling process. After sending the
  59.     signal, abort does an exit(127). Whether or not the \#atexit\# routines
  60.     will be called seems to be somewhat timing-sensitive.
  61.  
  62. RETURN VALUES
  63.     abort does not return.
  64.  
  65. SEE ALSO
  66.     \#exit\#, \#kill\#, \#signal\#\end
  67.  
  68. screen( capsensitive("abs"),
  69.         capsensitive("labs"))
  70. NAME
  71.     abs, labs - return integer or long absolute value
  72.  
  73. SYNOPSIS
  74.     #include <stdlib.h>
  75.  
  76.     int abs(int i);
  77.  
  78.     long labs(long i);
  79.  
  80. DESCRIPTION
  81.     abs returns the absolute value of its integer operand.
  82.     labs returns the absolute value of its long operand.
  83.  
  84. SEE ALSO
  85.     \#fabs\#
  86.  
  87. CAVEAT
  88.     In two's-complement representation, the absolute value of the
  89.     negative integer or long with the largest magnitude is undefined.
  90.     This error is not trapped in this implementation.\end
  91.  
  92. screen( capsensitive("bsearch"))
  93. NAME
  94.     bsearch - binary search a sorted table
  95.  
  96. SYNOPSIS
  97.     #include <stdlib.h>
  98.  
  99.     void *bsearch(const void *key, const void *base, 
  100.                   size_t total_elems, size_t elem_size, 
  101.                   int (*compare)(const void *one, const void *two));
  102.  
  103. DESCRIPTION
  104.     bsearch is a binary search routine generalized from Knuth
  105.     (6.2.1) Algorithm B. It returns a pointer into a table
  106.     indicating where a datum may be found. The table must be
  107.     previously sorted in increasing order according to a provided
  108.     comparison function.
  109.       - key points to a datum instance to be sought in
  110.         the table.
  111.       - base points to the element at the base of the table.
  112.       - total_elems is the number of elements in the table.
  113.       - elem_size is the size, in bytes, of each element
  114.         in the table.
  115.       - compare is the name of the comparison function,
  116.         which is called with two arguments that point to
  117.         the elements being compared. As the function must
  118.         return an integer less than, equal to, or greater
  119.         than zero, so must the first argument to be considered
  120.         be less than, equal to, or greater than the second.
  121.  
  122. EXAMPLE
  123.     The example below searches a table containing pointers to
  124.     nodes consisting of a string and its length. The table is
  125.     ordered alphabetically on the string in the node pointed
  126.     to by each entry.
  127.  
  128.     This code fragment reads in strings and either finds the
  129.     corresponding node, in which case it prints out the string
  130.     and its length, or it prints an error message.
  131.         #include <stdio.h>
  132.         #include <stdlib.h>
  133.         #include <string.h>
  134.         #define TABSIZE 1000
  135.         struct node /* These are stored in the table */
  136.         {
  137.           char *string;
  138.           int length;
  139.         };
  140.  
  141.         struct node table[TABSIZE]; /* Table to be searched */
  142.               .
  143.               .
  144.               .
  145.         {
  146.           struct node *node_ptr, node;
  147.           int node_compare(const struct *node1, const struct *node2);
  148.           char str_space[20]; /* space to read string into */
  149.           .
  150.           .
  151.           .
  152.           node.string = str_space;
  153.           while (scanf("%s", node.string) != EOF)
  154.           {
  155.             node_ptr = (struct node *)bsearch(&node, table, TABSIZE,
  156.                        sizeof(struct node), node_compare);
  157.             if (node_ptr != NULL)
  158.               printf("string = %20s, length = %d\\n", 
  159.                      node_ptr->string, node_ptr->length);
  160.             else
  161.               printf("not found: %s\\n", node.string);
  162.           }
  163.         }
  164.  
  165.         /* Compare two nodes based on an alphabetical */
  166.         /* ordering of the string field.              */
  167.         int node_compare(const void *table_node, const void *key_node)
  168.         {
  169.           const struct node *table = (const struct node *)table_node;
  170.           const struct node *key = (const struct node *)key_node;
  171.           
  172.           return(strcmp(table->string, key->string));
  173.         }
  174.  
  175. SEE ALSO
  176.     \#qsort\#
  177.  
  178. NOTES
  179.     The comparison function need not compare every byte, so
  180.     arbitrary data may be contained in the elements in addition
  181.     to the values being compared.
  182.  
  183.     A NULL pointer is returned if the key cannot be found in
  184.     the table.\end
  185.  
  186. screen( capsensitive("clock"))
  187. NAME
  188.     clock - report CPU time used
  189.  
  190. SYNOPSIS
  191.     #include <time.h>
  192.  
  193.     clock_t clock(void);
  194.  
  195. DESCRIPTION
  196.     clock returns the amount of time passed (in 200Hz clock ticks)
  197.     since the program was started.
  198.  
  199. SEE ALSO
  200.     \#times\#, \#getrusage\#
  201.  
  202. BUGS
  203.     This function is hopelessly different from the UN*X function clock,
  204.     which returns CPU time used by the program and all its terminated
  205.     children, instead of real time elapsed since the program started.\end
  206.  
  207. screen( capsensitive("opendir"),
  208.         capsensitive("readdir"),
  209.         capsensitive("telldir"),
  210.         capsensitive("seekdir"),
  211.         capsensitive("rewinddir"),
  212.         capsensitive("closedir"))
  213. NAME
  214.     directory, opendir, readdir, telldir, seekdir, rewinddir,
  215.     closedir - directory operations
  216.  
  217. SYNOPSIS
  218.     #include <dirent.h>
  219.  
  220.     DIR *opendir(const char *dirname);
  221.  
  222.     struct dirent *readdir(DIR *dirp);
  223.  
  224.     off_t telldir(DIR *dirp);
  225.  
  226.     void seekdir(DIR *dirp, off_t loc);
  227.  
  228.     void rewinddir(DIR *dirp);
  229.  
  230.     int closedir(DIR *dirp);
  231.  
  232. DESCRIPTION
  233.     opendir opens the directory named by dirname and associates
  234.     a directory stream with it. opendir returns a pointer to
  235.     be used to identify the directory stream in subsequent
  236.     operations. A NULL pointer is returned if dirname cannot be
  237.     accessed or is not a directory, or if it cannot \#malloc\# enough
  238.     memory to hold the whole thing.
  239.  
  240.     readdir returns a pointer to the next directory entry. It
  241.     returns NULL upon reaching the end of the directory or
  242.     detecting and invalid seekdir operation.
  243.  
  244.     telldir returns the current location associated with the
  245.     named directory stream.
  246.  
  247.     seekdir sets the position of the next readdir operation
  248.     on the directory stream. The new position reverts to the one
  249.     associated with the directory stream when the telldir
  250.     operation was performed. Values returned by telldir are
  251.     good only for the lifetime of the DIR pointer from which they
  252.     are derived. If the directory is closed and then reopened,
  253.     the telldir value may be invalidated due to changes in the
  254.     directory.
  255.  
  256.     rewinddir resets the position of the named directory stream
  257.     to the beginning of the directory. It also causes the
  258.     directory stream to refer to the current state of the
  259.     corresponding directory, as a call to opendir would have
  260.     done.
  261.  
  262.     closedir closes the named directory stream and frees the
  263.     structure associated with the DIR pointer.
  264.  
  265. RETURN VALUES
  266.     opendir returns a pointer of type DIR on success. On
  267.     failure, it returns NULL and sets errno to indicate the
  268.     error.
  269.  
  270.     readdir returns a pointer of object type struct dirent
  271.     on success. On failure, it returns NULL and sets errno
  272.     to indicate the error. When the end of the directory
  273.     is encountered, readdir returns NULL and leaves errno
  274.     unchanged. The dirent structure is defined in <dirent.h>
  275.     and contains the following fields of interest:
  276.       struct dirent
  277.       {
  278.         long    d_ino;      /* garbage under TOS emulation  */
  279.         off_t   d_off;      /* position in directory        */
  280.         short   d_reclen;   /* length of d_name             */
  281.         ...                 /* various TOS-emulation fields */
  282.         char    *d_name;    /* name of the current file     */
  283.       };
  284.  
  285.     closedir returns 0 on succes, EIHNDL on failure.
  286.  
  287.     telldir returns the current location associated with the
  288.     specified directory stream.
  289.  
  290. EXAMPLE
  291.     Sample code which searches a directory for entry `name' is:
  292.  
  293.         dirp = opendir(".");
  294.         for (dp = readdir(dirp); dp != NULL; dp = readdir(dirp))
  295.           if (!strcmp(dp->d_name, name))
  296.           {
  297.             closedir(dirp);
  298.             return (FOUND);
  299.           }
  300.         closedir(dirp);
  301.         return (NOT_FOUND);
  302.  
  303. SEE ALSO
  304.     \#Dopendir\#, \#Dreaddir\#, \#Dclosedir\#; these system calls are
  305.     used in the implementation of the directory routines.
  306.  
  307. NOTES
  308.     As memory is allocated at every call to opendir, every
  309.     call to opendir should be matched by a corresponding
  310.     call to closedir.
  311.     
  312.     When MiNT is not active, readdir calls are emulated under
  313.     TOS. When that happens, various fields in the dirent
  314.     structure are used that are undefined when MiNT is active.
  315.     It is therefore advisable not to use those fields.
  316.  
  317.     Because of an error in the mintlibs and a change in MiNT 0.97,
  318.     programs using readdir from the mintlibs pl 24 or below will
  319.     die in MiNT 0.97 or higher.\end
  320.  
  321. screen( capsensitive("exec")
  322.         capsensitive("execl"),
  323.         capsensitive("execv"),
  324.         capsensitive("execle"),
  325.         capsensitive("execlp"),
  326.         capsensitive("execve"),
  327.         capsensitive("execvp"))
  328. NAME
  329.     execl, execv, execle, execlp, execve, execvp - execute a file
  330.  
  331. SYNOPSIS
  332.     #include <unistd.h>
  333.  
  334.     int execl(char *path, ...);
  335.  
  336.     int execv(char *path, char *argv[]);
  337.  
  338.     int execle(char *path, ...);
  339.  
  340.     int execlp(char *file, ...);
  341.  
  342.     int execve(char *path, char *argv[], char *envp[]);
  343.  
  344.     int execvp(char *file, char *argv[]);
  345.  
  346. DESCRIPTION
  347.     These routines transform the calling process into a new process.
  348.     The program indicated by `path' or `file' is loaded, then run.
  349.     There can be no return from a succesful exec call.
  350.  
  351.     These calls differ in the following ways:
  352.     - execl, execle and execlp are called when the number of
  353.       arguments is known in advance, whereas execv, execve
  354.       and execvp take an argument vector.
  355.  
  356.     - execl, execv, execle and execve are called with the full
  357.       path name of the program to be run, whereas execlp and
  358.       execvp are called with a filename that is searched on
  359.       the user's search path and that may be extended with
  360.       the filename extensions ".ttp", ".tos" and ".prg".
  361.  
  362.     - execl, execv, execlp and execvp pass the parent's
  363.       environment to the new process, whereas execle and
  364.       execve take a pointer to an environment vector as
  365.       their final argument.
  366.  
  367.     The last argument to the execl, execle and execlp functions
  368.     should be a NULL pointer.
  369.  
  370.     An argument vector argv as used in execv, execve and execvp
  371.     is a pointer to a null-terminated array of character pointers
  372.     to null-terminated character strings. These strings constitute
  373.     the argument list to be made available to the new process.
  374.     By convention, at least one argument must be present in this
  375.     array, and the first element of this array should be the name
  376.     of the executed program. For execv and execve this is the last
  377.     component of the path argument; for execvp this is the file
  378.     argument.
  379.  
  380.     The environment vector envp as used in execle and execve is also
  381.     a pointer to a null-terminated array of character pointers to
  382.     null-terminated strings. These strings pass information to the
  383.     new process which are not directly arguments to the command.
  384.     If envp is NULL, a copy of the parent process' environment is
  385.     passed.
  386.  
  387.     Signals set to the default action (SIG_DFL) in the calling
  388.     process image are set to the default action in the new process.
  389.     Signals set to be ignored (SIG_IGN) by the calling process are
  390.     ignored by the new process. Signals set to be caught by the
  391.     calling process are reset to the default action in the new
  392.     process. Signals set to be blocked in the calling process remain
  393.     blocked in the new process, regardless of changes to the signal
  394.     action.
  395.  
  396. RETURN VALUES
  397.     These functions returns to the calling process only on failure,
  398.     for instance if the program called could not be found, if it
  399.     was not executable, or if not enough memory was available, in
  400.     which case -1 is returned and errno is set to indicate the error.
  401.  
  402. EXAMPLES
  403.       This will execute the program /bin/date or fail:
  404.     execl("/bin/date", "date", NULL);
  405.  
  406.       This will search the program sh and then execute it;
  407.       it will fail only if sh, sh.tos, sh.ttp and sh.prg
  408.       could not be found:
  409.     execlp("sh", "sh", "-c", commandline, NULL);
  410.  
  411.       This will call /bin/test using an already constructed
  412.       argument vector and an already constructed environment
  413.       vector, and fail if /bin/test could not be found:
  414.     execve("/bin/test", my_argv, my_envp);
  415.  
  416. SEE ALSO
  417.     \#fork\#, \#signal\#, \#tfork\#, \#vfork\#
  418.     \#_spawnve\# - this is the library call underlying all
  419.     these routines.
  420.  
  421. NOTES
  422.     When MiNT is not active, these library calls call a child
  423.     process and then \#_exit\# after the child has finished;
  424.     only when MiNT is active, the current process is truly
  425.     transformed into a new one.
  426.  
  427.     On Un*x, execve is a system call, while the rest of these
  428.     calls are library routines. Under MiNT, it's all done in
  429.     the library.\end
  430.  
  431. screen( capsensitive("fclose"),
  432.         capsensitive("fflush"))
  433. NAME
  434.     fclose, fflush - close or flush a stream
  435.  
  436. SYNOPSIS
  437.     #include <stdio.h>
  438.  
  439.     int fclose(FILE *stream);
  440.  
  441.     int fflush(FILE *stream);
  442.  
  443. DESCRIPTION
  444.     fclose writes out any buffered data for the named stream,
  445.     and closes the named stream. Buffers allocated by the
  446.     standard input/output system are freed.
  447.  
  448.     fclose is performed automatically for all open files upon
  449.     calling \#exit\#.
  450.  
  451.     fflush writes any unwritten data for an output stream or
  452.     an update stream in which the most recent operation was not
  453.     input to be delivered to the host environment to the file;
  454.     otherwise it is ignored. The named stream remains open.
  455.  
  456. RETURN VALUES
  457.     fclose returns:
  458.  
  459.       0 on success.
  460.     EOF if any error (such as trying to write to a file that
  461.         has not been opened for writing) was detected.
  462.  
  463.     fflush returns:
  464.  
  465.       0 on success or if the file wasn't open.
  466.     EOF if an error was detected while writing the data.
  467.     
  468. SEE ALSO
  469.     \#close\#, \#exit\#, \#fopen\#, \#setbuf\#\end
  470.  
  471. screen( capsensitive("ferror"),
  472.         capsensitive("feof"),
  473.         capsensitive("clearerr"),
  474.         capsensitive("fileno"))
  475. NAME
  476.     ferror, feof, clearerr, fileno - stream status enquiries
  477.  
  478. SYNOPSIS
  479.     #include <stdio.h>
  480.  
  481.     int ferror(FILE *stream);
  482.  
  483.     int feof(FILE *stream);
  484.  
  485.     void clearerr(FILE *stream);
  486.  
  487.     int fileno(FILE *stream);
  488.  
  489. DESCRIPTION
  490.     ferror returns non-zero when an I/O error has previously
  491.     occurred reading from or writing to the named stream,
  492.     otherwise zero.
  493.  
  494.     feof returns non-zero when EOF has previously been
  495.     detected reading the named input stream, otherwise zero.
  496.  
  497.     clearerr resets the error indicator and EOF indicator
  498.     to zero on the named stream.
  499.  
  500.     fileno returns the integer file descriptor associated
  501.     with the named stream.
  502.  
  503. SEE ALSO
  504.     \#open\#, \#fopen\#
  505.  
  506. NOTE
  507.     All these functions are implemented as macros; they
  508.     cannot be declared or redeclared.\end
  509.  
  510. screen( capsensitive("fopen"),
  511.         capsensitive("freopen"),
  512.         capsensitive("fdopen"))
  513. NAME
  514.     fopen, freopen, fdopen - open a stream
  515.  
  516. SYNOPSIS
  517.     #include <stdio.h>
  518.  
  519.     FILE *fopen(const char *filename, const char *type);
  520.  
  521.     FILE *freopen(const char *filename, const char *type,
  522.                   FILE *stream);
  523.  
  524.     FILE *fdopen(int fd, const char *type);
  525.  
  526. DESCRIPTION
  527.     fopen opens the file named by filename and associates a stream
  528.     with it. If the open succeeds, fopen returns a pointer to be
  529.     used to identify the stream in subsequent operations.
  530.  
  531.     filename points to a character string that contains the name
  532.     of the file to be opened.
  533.  
  534.     type is a character string starting with one the following
  535.     values:
  536.       r   - open for reading
  537.       w   - truncate or create for writing
  538.       a   - append: open for writing at end of file, or create
  539.             for writing
  540.       r+  - open for update (reading and writing)
  541.       w+  - truncate or create for update
  542.       a+  - append; open or create for update at EOF
  543.  
  544.     After one of the above, type may be followed by:
  545.       t   - open file in text mode (translate \\r\\n to \\n when
  546.             reading, and \\n to \\r\\n when writing)
  547.       b   - open file in binary mode (no \\r, \\n translation)
  548.  
  549.     If neither 't' nor 'b' is set, the file will be opened in the
  550.     default mode set by the user. If the environment variable
  551.     UNIXMODE contains the letter 'b', the default mode will be
  552.     binary; otherwise, the default mode is text mode.
  553.  
  554.     freopen opens the file named by filename and associates the
  555.     stream pointed to by stream with it. The type argument is used
  556.     just as in fopen. The original stream is closed, regardless of
  557.     whether the open ultimately succeeds. If the open succeeds,
  558.     freopen returns the original value of stream.
  559.  
  560.     freopen is typically used to attach the preopened streams
  561.     associated with stdin, stdout, and stderr to other files.
  562.  
  563.     fdopen associates a stream with the file descriptor fd.
  564.     File descriptors are obtained from calls like \#open\#, \#dup\#,
  565.     \#creat\#, or \#pipe\#, which open files but do not return streams.
  566.     Streams are necessary input for many of the library routines.
  567.     The type of the stream must agree with the access permissions
  568.     of the open file.
  569.  
  570.     When a file is opened for update, both input and output may
  571.     be done on the resulting stream. However, output may not be
  572.     directly followed by input without an intervening \#fseek\# or
  573.     \#rewind\#, and input may not be directly followed by output
  574.     without an intervening \#fseek\#, \#rewind\#, or an input operation
  575.     which encounters EOF.
  576.  
  577. RETURN VALUES
  578.     On  success, fopen, freopen, and fdopen return a pointer to
  579.     FILE which identifies the opened stream.
  580.     On failure, they return NULL.
  581.  
  582. SEE ALSO
  583.     \#open\#, \#pipe\#, \#fclose\#, \#fseek\#
  584.  
  585. BUGS
  586.     The library allows only a limited number of streams to be open
  587.     at the same time. Thus, a program may run out of streams even
  588.     though the system is not yet out of memory.\end
  589.  
  590. screen( capsensitive("fread"),
  591.         capsensitive("fwrite"))
  592. NAME
  593.     fread, fwrite - buffered binary input/output
  594.  
  595. SYNOPSIS
  596.     #include <stdio.h>
  597.  
  598.     size_t fread (void *ptr, size_t size, size_t nitems, 
  599.                   FILE *stream);
  600.  
  601.     size_t fwrite (const void *ptr, size_t size, size_t nitems,
  602.                    FILE *stream);
  603.  
  604. DESCRIPTION
  605.     fread reads, into a block pointed to by ptr, nitems items
  606.     of data from the named input stream stream, where an item of
  607.     data is a sequence of bytes (not necessarily terminated by a
  608.     null byte) of length size. It returns the number of items
  609.     actually read. fread stops reading if an end-of-file or
  610.     error condition is encountered while reading from stream, or
  611.     if nitems items have been read. fread leaves the file
  612.     pointer in stream, if defined, pointing to the byte follow-
  613.     ing the last byte read if there is one. fread does not
  614.     change the contents of the file referred to by stream.
  615.  
  616.     fwrite writes at most nitems items of data from the block
  617.     pointed to by ptr to the named output stream stream. It
  618.     returns the number of items actually written. fwrite
  619.     stops writing when it has written nitems items of data or if
  620.     an error condition is encountered on stream. fwrite does
  621.     not change the contents of the block pointed to by ptr.
  622.  
  623.     If size or nitems is non-positive, no characters are read or
  624.     written and 0 is returned by both fread and fwrite.
  625.  
  626. RETURN VALUES
  627.     fread and fwrite return the number of elements read on
  628.     success, 0 on failure.
  629.  
  630. SEE ALSO
  631.     \#read\#, \#write\#, \#fopen\#, \#getc\#, \#gets\#, \#putc\#, \#puts\#, \#printf\#, \#scanf\#\end
  632.  
  633. screen( capsensitive("fseek"),
  634.         capsensitive("ftell"),
  635.         capsensitive("rewind"))
  636. NAME
  637.     fseek, ftell, rewind - reposition a stream
  638.  
  639. SYNOPSIS
  640.     #include <stdio.h>
  641.  
  642.     fseek(FILE *stream, long offset, int mode);
  643.  
  644.     long ftell(FILE *stream);
  645.  
  646.     void rewind(FILE *stream);
  647.  
  648. DESCRIPTION
  649.     fseek sets the position of the next input or output operation
  650.     on the stream. The parameter offset determines the new position
  651.     according to the parameter mode:
  652.       SEEK_SET (0): offset bytes from the start of the file
  653.       SEEK_CUR (1): offset bytes further than the current
  654.                     position
  655.       SEEK_END (2): offset bytes from the end of the file
  656.  
  657.     rewind is equivalent to fseek(stream, 0L, 0), except that no
  658.     value is returned.
  659.  
  660.     ftell returns the offset of the current byte relative to
  661.     the beginning of the file associated with the named stream.
  662.  
  663.     fseek and rewind undo any effects of \#ungetc\#.
  664.  
  665.     After fseek or rewind, the next operation on a file
  666.     opened for update may be either input or output.
  667.  
  668. RETURN VALUES
  669.     fseek returns 0 on success, -1 on failure.
  670.  
  671.     ftell returns a position >= 0 on success, -1 on failure.
  672.  
  673. SEE ALSO
  674.     \#lseek\#, \#fopen\#, \#popen\#, \#ungetc\#\end
  675.  
  676. screen( capsensitive("ftw"))
  677. NAME
  678.     ftw - walk a file tree
  679.  
  680. SYNOPSIS
  681.     #include <ftw.h>
  682.  
  683.     int ftw(char *path, int (*fn)(char *, struct stat *, int), int depth);
  684.  
  685. DESCRIPTION
  686.     ftw recursively descends the directory hierarchy rooted in path.
  687.     For each object in the hierarchy, ftw calls the user-supplied
  688.     function fn, passing it a pointer to a null-terminated character
  689.     string containing the name of the object, a pointer to a stat
  690.     structure containing information about the object, and an integer.
  691.     Possible values of the integer, defined in the <ftw.h> header file,
  692.     are FTW_F for a file, FTW_D for a directory, FTW_DNR for a directory
  693.     that cannot be read, and FTW_NS for an object for which \#stat\# could
  694.     not successfully be executed. If the integer is FTW_DNR, descendants
  695.     of that directory will not be processed. An example of an object
  696.     that would cause FTW_NS to be passed to fn would be a file in a
  697.     directory with read but without execute (search) permission.
  698.  
  699.     ftw visits a directory before visiting any of its descendants.
  700.  
  701.     The tree traversal continues until the tree is exhausted, an
  702.     invocation of fn returns a nonzero value, or some error is
  703.     detected within ftw (such as an I/O error). If the tree is
  704.     exhausted, ftw returns zero. If fn returns a nonzero value,
  705.     ftw stops its tree traversal and returns whatever value was
  706.     returned by fn. If ftw detects an error, it returns -1, and
  707.     sets the error type in errno.
  708.  
  709.     ftw uses one file descriptor for each level in the tree. The
  710.     depth argument limits the number of file descriptors so used.
  711.     If depth is zero or negative, the effect is the same as if it
  712.     were 1. Depth must not be greater than the number of file
  713.     descriptors currently available for use. ftw will run more
  714.     quickly if depth is at least as large as the number of levels
  715.     in the tree.
  716.  
  717. SEE ALSO
  718.     \#stat\#
  719.  
  720. NOTES
  721.     Note that MiNT limits each process to 32 file descriptors. Since three
  722.     are normally used for standard input, output and error output, only few
  723.     remain.
  724.  
  725.     C library functions like this are usually only found after a similar
  726.     version has already been written by the programmer.
  727.  
  728. BUGS
  729.     Because ftw is recursive, it is possible for it to terminate with a
  730.     memory fault when applied to very deep file structures.
  731.  
  732.     Symbolic links are reported to the user-supplied function as FTW_F.\end
  733.  
  734. screen( capsensitive("getgrent"),
  735.         capsensitive("getgrgid"),
  736.         capsensitive("getgrnam"),
  737.         capsensitive("setgrent"),
  738.         capsensitive("endgrent"),
  739.         capsensitive("fgetgrent"))
  740. NAME
  741.     getgrent, getgrgid, getgrnam, setgrent, endgrent, fgetgrent -
  742.     get group file entry
  743.  
  744. SYNOPSIS
  745.     #include <stdio.h>
  746.     #include <grp.h>
  747.  
  748.     struct group *getgrent(void);
  749.  
  750.     struct group *getgrgid(int gid);
  751.  
  752.     struct group *getgrnam(const char *name);
  753.  
  754.     void setgrent(void);
  755.  
  756.     void endgrent(void);
  757.  
  758.     struct group *fgetgrent(FILE *f);
  759.  
  760. DESCRIPTION
  761.     getgrent, getgrgid and getgrnam each returns a pointer to an
  762.     object containing the broken-out fields of a line in the
  763.     /etc/group file.
  764.     Each line in the file contains a "group" structure, declared
  765.     in the <grp.h> header file:
  766.       struct group
  767.       {
  768.         char  *gr_name;   /* name of the group     */
  769.         char  *gr_passwd; /* encrypted password    */
  770.         gid_t gr_gid;     /* numerical group ID    */
  771.         char  **gr_mem;   /* array of member names */
  772.       };
  773.  
  774.     getgrent when first called returns a pointer to the first
  775.     group structure in the file; thereafter, it returns a pointer
  776.     to the next group structure in the file; so successive calls
  777.     can be used to search the entire file.
  778.  
  779.     getgrgid searches from the beginning of the file until a
  780.     numerical group ID is found matching gid is found and returns
  781.     a pointer to the particular structure in which it was found.
  782.     Thus, it cannot be found to search for several groups having
  783.     duplicate numerical group IDs.
  784.  
  785.     getgrnam searches from the beginning of the file until a
  786.     group name matching name is found and returns a pointer to
  787.     the particular structure in which it was found.
  788.  
  789.     If an EOF or an error is encountered on reading, getgrent,
  790.     getgrgid and getgrnam return a NULL pointer.
  791.  
  792.     A call to setgrent has the effect of rewinding the group
  793.     file to allow repeated searches.
  794.  
  795.     endgrent may be called to close the group file when
  796.     processing is complete.
  797.  
  798.     fgetgrent returns a pointer to the next group structure in
  799.     the stream f, which matches the format of /etc/group.
  800.  
  801. FILES
  802.     /etc/group
  803.  
  804. SEE ALSO
  805.     \#getlogin\#, \#getpwent\#
  806.  
  807. NOTES
  808.     All information is contained in a static area, so it must
  809.     be copied if it is to be saved.
  810.  
  811.     These routines cannot handle groups with over 128 members.
  812.  
  813.     These routines expect the group file to be of type text,
  814.     and can therefore read both DOS and UN*X format files.
  815.  
  816.     fgetgrent is not standard, but is available on System V.
  817.  
  818.     For group files, there's no equivalent to \#putpwent\#.
  819.  
  820.     The password field of groups is seldom used.\end
  821.  
  822. screen( capsensitive("getlogin"))
  823. NAME
  824.     getlogin - get login name
  825.  
  826. SYNOPSIS
  827.     #include <unistd.h>
  828.  
  829.     char *getlogin(void);
  830.  
  831. DESCRIPTION
  832.     getlogin returns a pointer to the user's login name.
  833.     This is determined in the following way:
  834.       - The name for the current userid is read from the
  835.         password file using \#getuid\# and \#getpwuid\#.
  836.       - If this fails, the environment variable USER is read.
  837.       - If this fails, "user" is returned.
  838.  
  839.     This call returns a pointer to a dynamically allocated
  840.     area of memory. Consecutive calls will return the same
  841.     pointer.
  842.  
  843. SEE ALSO
  844.     \#cuserid\#, \#getgrent\#, \#getpwent\#, \#getpwuid\#, \#getuid\#
  845.  
  846. NOTES
  847.     The method used to determine the user's login name,
  848.     getpwuid(getuid()), is supposed to be the most reliable
  849.     way. It will fail if several users have identical numerical
  850.     userids, though. 
  851.  
  852.     On System V, this routine will read from /etc/utmp in order
  853.     to find out the current user's login name. This method can
  854.     be fooled by changing the terminal associated with standard
  855.     input, and thus is no viable alternative.\end
  856.  
  857. screen( capsensitive("getopt"),
  858.         capsensitive("optarg"),
  859.         capsensitive("optind"),
  860.         capsensitive("opterr"))
  861. NAME
  862.     getopt - get option letter from argument vector
  863.  
  864. SYNOPSIS
  865.     #include <unistd.h>
  866.  
  867.     int getopt(int argv, char * const *argv, const char *optstring);
  868.  
  869.     extern char *optarg;
  870.  
  871.     extern int optind;
  872.  
  873.     extern int opterr;
  874.  
  875. DESCRIPTION
  876.     getopt returns the next option letter in argv that matches a
  877.     letter in optstring. It supports all the rules of the UN*X
  878.     System V command syntax standard (see the section RULES below).
  879.     All new programs that wish to adhere to the command syntax standard
  880.     should use getopt to parse positional parameters and check for
  881.     options that are legal for that command.
  882.  
  883.     optstring must contain the option letters the command using
  884.     getopt will recognize; if a letter is followed by a colon,
  885.     the option is expected to have an argument, or group of
  886.     arguments, which must be separated from it by white space.
  887.  
  888.     optarg is set to point to the start of the option-argument
  889.     on return from getopt.
  890.  
  891.     getopt places in optind the argv index of the next argument to
  892.     be processed. optind is external and is initialized to 1 before
  893.     the first call to getopt.
  894.  
  895.     When all options have been processed (i.e., up to the first
  896.     non-option argument), getopt returns EOF. The special option
  897.     "--" may be used to delimit the end of the options; when it is
  898.     encountered, EOF will be returned, and "--" will be skipped.
  899.  
  900. DIAGNOSTICS
  901.     getopt prints an error message on standard error and returns
  902.     a question mark (?) when it encounters an option letter not
  903.     included in optstring or no option-argument after an option
  904.     that expects one. This error message may be disabled by setting
  905.     opterr to 0.
  906.  
  907. RULES
  908.     The UN*X System V command standard contains the following rules:
  909.  
  910.      1. Command names must be between two and nine characters long.
  911.      2. Command names must include only lower-case letters and digits.
  912.      3. Option names must be one character long.
  913.      4. All options must be preceded by "-".
  914.      5. Options with no arguments may be grouped with a single "-".
  915.      6. The first option-argument following an option must be
  916.         preceded by white space.
  917.      7. Option-arguments cannot be optional.
  918.      8. Groups of option-arguments following an option must be either
  919.         be separated by commas or separated by white space and quoted
  920.         (e.g.,  -o xxx,z,yy  or  -o "xxx z yy").
  921.      9. All options must precede operands on the command line.
  922.     10. "--" may be used to indicate the end of the options.
  923.     11. The order of the options relative to another should not matter.
  924.     12. The relative order of the operands may effect their
  925.         significance in ways determined by the command with which
  926.         they appear.
  927.     13. "-" preceded and followed by white space should only be used
  928.         to mean standard input.
  929.  
  930.     getopt supports rules 3-10 above; the enforcement of the other
  931.     rules must be done by the command itself.
  932.  
  933. EXAMPLE
  934.     The following code fragment shows how one might process the
  935.     arguments for a command that can take the mutually exclusive
  936.     options 'a' and 'b', and the option 'o', which requires an
  937.     option-argument.
  938.  
  939.     #include <stdio.h>
  940.     #include <stdlib.h>
  941.     #include <unistd.h>
  942.     extern char *optarg;
  943.  
  944.     void main(int argc, char *argv[])
  945.     {
  946.       int  c, aflg = 0, bflg = 0, errflg = 0;
  947.       char *ofile = NULL;
  948.  
  949.       while ((c = getopt(argc, argv, "abo:")) != EOF)
  950.         switch (c)
  951.         {
  952.           case 'a':
  953.             if (bflg != 0)
  954.               errflg++;
  955.             else
  956.               aflg++;
  957.             break;
  958.           case 'b':
  959.             if (aflg != 0)
  960.               errflg++;
  961.             else
  962.               bflg++;
  963.             break;
  964.           case 'o':
  965.             ofile = optarg;
  966.             break;
  967.           case '?':
  968.             errflg++;
  969.         }
  970.       if (errflg != 0)
  971.       {
  972.         fprintf(stderr, "Usage:...\\n");
  973.         exit(1);
  974.       }
  975.       ...
  976.     }
  977.  
  978. NOTES
  979.     getopt cannot be used for complicated context-sensitive
  980.     argument vector parsing.
  981.  
  982.     The UN*X System V standard may seem too restrictive; for instance,
  983.     in the above example, '-ofile' is not allowed ('-o file' is).
  984.  
  985.     Some systems return -1 instead of EOF; this may actually make a
  986.     difference on some systems.\end
  987.  
  988. screen( capsensitive("getpass"))
  989. NAME
  990.     getpass - read a password
  991.  
  992. SYNOPSIS
  993.     #include <unistd.h>
  994.  
  995.     char *getpass(const char *prompt);
  996.  
  997. DESCRIPTION
  998.     getpass reads up to a newline or EOF from standard input (TOS)
  999.     or /dev/tty (MiNT), after prompting on the standard error output
  1000.     with the null-terminated string prompt and disabling echoing.
  1001.     A pointer is returned to a null-terminated string of at most 
  1002.     PASS_MAX characters. PASS_MAX is defined in <limits.h> and has
  1003.     curently been set to 8.
  1004.  
  1005. WARNING
  1006.     getpass uses <stdio.h>, which may cause an unexpected increase
  1007.     in the size of a program not otherwise using standard I/O.
  1008.  
  1009.     The return value points to static data whose contents is
  1010.     overwritten by each call.\end
  1011.  
  1012. screen( capsensitive("getrlimit"),
  1013.         capsensitive("setrlimit"))
  1014. NAME
  1015.     getrlimit, setrlimit - control maximum system resource  con-
  1016.     sumption
  1017.  
  1018. SYNOPSIS
  1019.     #include <sys/time.h>
  1020.     #include <sys/resource.h>
  1021.  
  1022.     int getrlimit(int kind, struct rlimit *rlp);
  1023.  
  1024.     int setrlimit(int kind, struct rlimit *rlp);
  1025.  
  1026. DESCRIPTION
  1027.     Limits on the consumption of system resources by the current
  1028.     process and each process it creates may be obtained with the
  1029.     getrlimit call, and set with the setrlimit call. These
  1030.     functions only work for real if MiNT is active.
  1031.  
  1032.     The following resource parameters are allowed:
  1033.  
  1034.       RLIMIT_CPU    the maximum amount of cpu time (in
  1035.                     milliseconds) to be used by each process.
  1036.  
  1037.       RLIMIT_FSIZE  the largest size, in bytes, of any single
  1038.                     file that may be created.
  1039.  
  1040.       RLIMIT_DATA   the maximum size, in bytes, of the data
  1041.                     the process may allocate with \#Malloc\#.
  1042.  
  1043.       RLIMIT_STACK  the maximum size, in bytes, of the stack
  1044.                     segment for a process.
  1045.                     
  1046.       RLIMIT_CORE   the largest size, in bytes, of a core file
  1047.                     that may be created.
  1048.                     
  1049.       RLIMIT_RSS    the maximum size, in bytes, allowed for
  1050.                     the process.
  1051.  
  1052.     Of these, only the RLIMIT_CPU, RLIMIT_DATA and RLIMIT_RSS
  1053.     parameters are supported. The others do nothing. The UN*X
  1054.     parameter RLIMIT_NOFILE is not available in the header file
  1055.     at all. Also, the value of the RLIMIT_CPU parameter is in
  1056.     milliseconds, while the UN*X version is specified in seconds.
  1057.  
  1058.     A resource limit is specified as a soft limit and a hard
  1059.     limit. When a soft limit is exceeded a process receives
  1060.     a signal SIGXCPU if the cpu time is exceeded; memory
  1061.     allocations will fail if RLIMIT_DATA or RLIMIT_RSS is
  1062.     exceeded. Hard limits are not enforced at all.
  1063.  
  1064.     The struct rlimit is defined as follows:
  1065.       struct rlimit
  1066.       {
  1067.         long rlim_cur; /* current (soft) limit       */
  1068.         long rlim_max; /* hard limit (not supported) */
  1069.       };
  1070.  
  1071.     Contradicting the UN*X version, any process may increase
  1072.     its limits at will.
  1073.  
  1074.     An "infinite" value for a limit is defined as RLIM_INFINITY
  1075.     (0x7fffffff).
  1076.  
  1077. RETURN VALUES
  1078.     getrlimit and setrlimit return:
  1079.  
  1080.      0  on success.
  1081.     -1  on failure; errno is set to EINVAL.
  1082.  
  1083. SEE ALSO
  1084.     \#Psetlimit\# - this system call is used in the implementation
  1085.     of these routines.
  1086.     \#getrusage\#, \#signal\#
  1087.  
  1088. BUGS
  1089.     These functions are so different from their UN*X equivalents
  1090.     that they are practically worthless.\end
  1091.  
  1092. screen( capsensitive("gets"),
  1093.         capsensitive("fgets"))
  1094. NAME
  1095.     gets, fgets - get a string from a stream
  1096.  
  1097. SYNOPSIS
  1098.     #include <stdio.h>
  1099.  
  1100.     char *gets(char *s);
  1101.  
  1102.     char *fgets(char *s, int n, FILE *stream);
  1103.  
  1104. DESCRIPTION
  1105.     gets reads characters from the standard input stream, stdin,
  1106.     into the array pointed to by s, until a new-line character
  1107.     is read or an end-of-file condition is encountered. The
  1108.     new-line character is discarded and the string is terminated
  1109.     with a null character.
  1110.  
  1111.     fgets reads character from the file stream into the array
  1112.     pointed to by s, until n-1 characters are read, or a new-line
  1113.     character is read and transferred to s, or an end-of-file
  1114.     condition is encountered. The string is then terminated
  1115.     with a null character.
  1116.  
  1117. SEE ALSO
  1118.     \#ferror\#, \#fopen\#, \#fread\#, \#getc\#, \#scanf\#
  1119.  
  1120. RETURN VALUES
  1121.     If end-of-file is encountered and no characters have been
  1122.     read, no characters are transferred to s and a NULL pointer
  1123.     is returned. If a read error occurs, such as trying to use
  1124.     these functions on a file that has not been opened for
  1125.     reading, a NULL pointer is returned. Otherwise s is returned.\end
  1126.  
  1127. screen( capsensitive("getwd"),
  1128.         capsensitive("getcwd"))
  1129. NAME
  1130.     getwd, getcwd - get path-name of current working directory
  1131.  
  1132. SYNOPSIS
  1133.     #include <unistd.h>
  1134.  
  1135.     char *getwd(char *buf);
  1136.  
  1137.     char *getcwd(char *buf, int size);
  1138.  
  1139. DESCRIPTION
  1140.     getcwd returns a pointer to the current directory path name.
  1141.     The value of size is the maximum length of the name to be
  1142.     returned. If buf is a NULL pointer, getcwd will obtain size
  1143.     bytes of space using \#malloc\#. It is up to the calling
  1144.     process to free this buffer.
  1145.  
  1146.     getwd is equivalent to getcwd(buf, PATH_MAX). Since PATH_MAX
  1147.     is the length of the longest path name allowed, this buffer
  1148.     should always be sufficient. Still, the use of this function
  1149.     is discouraged, since it is not specified in POSIX and may
  1150.     therefore be unavailable on other systems.
  1151.  
  1152. SEE ALSO
  1153.     \#chdir\#, \#malloc\#
  1154.     \#Dgetcwd\#, \#Dgetdrv\#, \#Dgetpath\#; these system calls are used
  1155.     in the implementation of these routines.
  1156.  
  1157. RETURN VALUES
  1158.     These functions return NULL is buf is NULL and no memory could
  1159.     be allocated; otherwise, a pointer to buf is returned.
  1160.     
  1161. NOTES
  1162.     On TOS and MiNT before 0.96, the size parameter to getcwd is only
  1163.     used for allocating memory; this functions are not yet safe,
  1164.     i.e. buf may overflow.
  1165.  
  1166.     On UN*X System V.3, the getcwd function was implemented using
  1167.     popen() and the pwd command! There had to be a better way...\end
  1168.  
  1169. screen( capsensitive("isatty"))
  1170. NAME
  1171.     isatty - is this file desciptor a terminal device
  1172.  
  1173. SYNOPSIS
  1174.     #include <unistd.h>
  1175.  
  1176.     int isatty(int fildes);
  1177.  
  1178. DESCRIPTION
  1179.     isatty returns 1 if file descriptor fildes is associated with a
  1180.     terminal device, 0 otherwise.
  1181.  
  1182. SEE ALSO
  1183.     \#ttyname\#
  1184.  
  1185. NOTE
  1186.     The current implementation makes use of the \#Fseek\# system call,
  1187.     which may explain the appearance of the \#Fseek\# call in system
  1188.     debug messages whenever a program tries to determine whether it
  1189.     is writing to a file or to a tty.\end
  1190.  
  1191. screen( capsensitive("malloc"),
  1192.         capsensitive("free"),
  1193.         capsensitive("realloc"),
  1194.         capsensitive("calloc"),
  1195.         capsensitive("alloca") )
  1196. NAME
  1197.     malloc, free, realloc, calloc, alloca - memory allocator
  1198.  
  1199. SYNOPSIS
  1200.     #include <stdlib.h>
  1201.  
  1202.     void *malloc(size_t size);
  1203.  
  1204.     void free(void *ptr);
  1205.  
  1206.     void *realloc(void *ptr, size_t size);
  1207.  
  1208.     void *calloc(size_t num_elems, size_t elem_size);
  1209.  
  1210.     void *alloca(size_t size);
  1211.  
  1212. DESCRIPTION
  1213.     These routines provide a general-purpose memory allocation
  1214.     package. They maintain a table of free blocks for efficient
  1215.     allocation and coalescing of free storage. When there is no
  1216.     suitable space already free, the allocation routines call
  1217.     \#Malloc\# to get more memory from the system.
  1218.  
  1219.     Each of the allocation routines returns a pointer to space
  1220.     suitably aligned for storage of any type of object. Each
  1221.     returns a NULL pointer if the request cannot be completed or
  1222.     if an area of size zero is requested.
  1223.  
  1224.     malloc returns a pointer to a block of at least size bytes.
  1225.  
  1226.     free releases a previously allocated block. Its argument
  1227.     is a pointer to a block previously allocated by malloc,
  1228.     calloc or realloc.
  1229.  
  1230.     realloc changes the size of a block referenced to by ptr
  1231.     to size bytes and returns a pointer to the (possibly moved)
  1232.     block. The contents will be unchanged up to the lesser of
  1233.     the new and old sizes. If unable to honor a reallocation
  1234.     request, realloc leaves it first argument unaltered.
  1235.     Using realloc with a block freed before is an error.
  1236.  
  1237.     realloc(NULL, size) is the same as malloc(size).
  1238.     realloc(ptr, 0) is the same as free(ptr).
  1239.  
  1240.     calloc uses malloc to allocate space for an array of
  1241.     num_elems elements of size elem_size, initialises the space
  1242.     to zeros, and returns a pointer to the initialised block.
  1243.  
  1244.     alloca allocates size bytes of space in the stack frame
  1245.     of the caller, and returns a pointer to the allocated block.
  1246.     This temporary space is automatically freed when the caller
  1247.     returns. Note that if the allocated block is beyond the
  1248.     current stack limit, the resulting behavior is undefined.
  1249.  
  1250. RETURN VALUES
  1251.     On success, malloc, calloc, realloc and alloca
  1252.     return a pointer to space suitably aligned for storage
  1253.     of any type of object. On failure, they return NULL.
  1254.  
  1255. SEE ALSO
  1256.     \#Malloc\#, \#getrlimit\#
  1257.  
  1258. WARNINGS
  1259.     On UN*X machines, malloc and realloc return a non-NULL pointer
  1260.     if size is 0, and calloc returns a non-NULL pointer if num_elems
  1261.     or elem_size is 0. The mintlibs follow the ANSI-C standard and
  1262.     return NULL in these circumstances.
  1263.  
  1264.     alloca is machine-, compiler-, and most of all, system-
  1265.     dependent. Its use is strongly discouraged. 
  1266.  
  1267. NOTES
  1268.     GNU software is uncommonly fond of alloca.
  1269.  
  1270.     To use alloca with Pure-C in the current version of
  1271.     the mintlibs, the caller must be compiled with the -S
  1272.     option set or the program will crash.\end
  1273.  
  1274. screen( capsensitive("mktemp"))
  1275. NAME
  1276.     mktemp - make a unique file name
  1277.  
  1278. SYNOPSIS
  1279.     #include <unistd.h>
  1280.  
  1281.     char *mktemp(char *template);
  1282.  
  1283. DESCRIPTION
  1284.     mktemp creates a unique file name, typically in a temporary
  1285.     filesystem, by replacing template with a unique file name, 
  1286.     and returns the address of template. The string in template 
  1287.     should contain a file name with six trailing Xs; mktemp
  1288.     replaces the Xs with a number and the current process ID. 
  1289.     The number will be chosen so that the resulting name does not
  1290.     duplicate an existing file. 
  1291.  
  1292. RETURN VALUES
  1293.     mktemp returns a pointer to the changed template on success,
  1294.     and NULL on failure.
  1295.  
  1296. SEE ALSO
  1297.     \#getpid\#, \#open\#, \#tmpfile\#, \#tmpnam\#
  1298.  
  1299. NOTES
  1300.     The related UN*X function mkstemp is currently not available
  1301.     in the mintlibs.
  1302.  
  1303.     mktemp actually changes the template string which you pass; 
  1304.     this means that you cannot use the same template string more
  1305.     than once - you need a fresh template for every unique file
  1306.     you want to open.
  1307.  
  1308.     When mktemp is creating a new unique filename it checks for
  1309.     the prior existence of a file with that name. This means that
  1310.     if you are creating more than one unique filename, it is bad
  1311.     practice to use the same root template for multiple invocations
  1312.     of mktemp.
  1313.  
  1314.     The current process id is used only if there is enough room in
  1315.     the string and MiNT is active.
  1316.  
  1317. BUGS
  1318.     It is possible to run out of numbers.\end
  1319.  
  1320. screen( capsensitive("perror"),
  1321.         capsensitive("errno"),
  1322.         capsensitive("sys_errlist"),
  1323.         capsensitive("sys_nerr"),
  1324.         capsensitive("strerror"))
  1325. NAME
  1326.     perror, errno, sys_errlist, sys_nerr, strerror - system error messages
  1327.  
  1328. SYNOPSIS
  1329.     #include <stdio.h>
  1330.  
  1331.     void perror(const char *s);
  1332.  
  1333.     #include <errno.h>
  1334.  
  1335.     extern int errno;
  1336.  
  1337.     extern char *sys_errlist[];
  1338.  
  1339.     extern int sys_nerr;
  1340.  
  1341.     #include <string.h>
  1342.  
  1343.     char *strerror(int errnum);
  1344.  
  1345. DESCRIPTION
  1346.     perror produces a message on the standard error output, describing
  1347.     the last error encountered during a call to a system or library
  1348.     function. The argument string s is printed first, then a colon
  1349.     and a blank, then the message and a new-line. (However, if s is
  1350.     NULL or s is an empty string the colon is not printed.) To be of
  1351.     most use, the argument string should include the name of the
  1352.     program that incurred the error. The error number is taken from
  1353.     the external variable errno, which is set when errors occur but
  1354.     not cleared when non-erroneous calls are made.
  1355.  
  1356.     To simplify variant formatting of messages, the array of message
  1357.     strings sys_errlist is provided; errno can be used as an index
  1358.     into this table to get the message string without the new-line.
  1359.     sys_nerr is the number of messages in the table; it should be
  1360.     checked because new error codes may be added to the system before
  1361.     they are added to the table.
  1362.  
  1363.     The string function strerror takes an error code as its argument
  1364.     and returns the corresponding message; since it checks sys_nerr,
  1365.     it may be easier of safer to use than sys_errlist.
  1366.  
  1367. NOTES
  1368.     On UN*X, the string s may be empty, but may not always be NULL.
  1369.  
  1370.     Not all UN*X or POSIX error codes are supported by the mintlibs.\end
  1371.  
  1372. screen( capsensitive("psignal"),
  1373.         capsensitive("signal_names"),
  1374.         capsensitive("sys_siglist"))
  1375. NAME
  1376.     psignal, sys_siglist, signal_names - system signal messages
  1377.  
  1378. SYNOPSIS
  1379.     #include <unistd.h>
  1380.  
  1381.     void psignal (int sig, const char *s);
  1382.  
  1383.     #include <siglist.h>
  1384.  
  1385.     extern char *sys_siglist[];
  1386.     
  1387.     extern char *signal_names[]; // Should not be used
  1388.  
  1389. DESCRIPTION
  1390.     psignal produces a message on the standard error output
  1391.     describing the indicated signal. The argument string s is
  1392.     printed first, then a colon and a blank, then the name of
  1393.     the signal and a new-line. (However, if s is NULL or s is 
  1394.     an empty string the colon is not printed.) To be of most
  1395.     use,  the argument string should include the name of the
  1396.     program that incurred the signal. The signal number should
  1397.     be from among those found in <signal.h>.
  1398.  
  1399.     To simplify variant formatting of messages, the array of
  1400.     messages sys_siglist is provided; the signal number can be
  1401.     used as an index into this table to get the signal name
  1402.     without the new-line. The constant NSIG defined in the
  1403.     include file <signal.h> is the number of messages provided
  1404.     for in the table.
  1405.  
  1406.     The array of signal names signal_names has also been
  1407.     provided; it is there only for backward compatibility
  1408.     purposes, and should not be used.
  1409.  
  1410. NOTES
  1411.     On UN*X, the string s may be empty, but may not always be NULL.
  1412.  
  1413.     MiNT signals are rather different from UN*X and POSIX.\end
  1414.  
  1415. screen( capsensitive("puts"),
  1416.         capsensitive("fputs"))
  1417. NAME
  1418.     puts, fputs - put a string on a stream
  1419.  
  1420. SYNOPSIS
  1421.     #include <stdio.h>
  1422.  
  1423.     int puts(const char *s);
  1424.  
  1425.     int fputs(const char *s, FILE *stream);
  1426.  
  1427. DESCRIPTION
  1428.     puts writes the null-terminated string pointed to by s,
  1429.     followed by a new-line character, to the standard output
  1430.     stream stdout.
  1431.  
  1432.     fputs writes the null-terminated string pointed to by s
  1433.     to the named output file stream.
  1434.  
  1435.     Neither function writes the terminating null character.
  1436.  
  1437. SEE ALSO
  1438.     \#ferror\#, \#fopen\#, \#fread\#, \#printf\#, \#putc\#
  1439.  
  1440. RETURN VALUES
  1441.     These routines return EOF on error.
  1442.     Otherwise, the number of bytes written is returned.
  1443.  
  1444. NOTE
  1445.     puts appends a new-line character while fputs does not.\end
  1446.  
  1447. screen( capsensitive("rand"),
  1448.         capsensitive("srand"))
  1449. NAME
  1450.     rand, srand - simple random number generator
  1451.  
  1452. SYNOPSIS
  1453.     #include <stdlib.h>
  1454.  
  1455.     int rand(void);
  1456.  
  1457.     void srand(unsigned int seed);
  1458.  
  1459. DESCRIPTION
  1460.     rand is a simple random number generator that returns pseudo-
  1461.     random numbers in the range 0 to 2^15 - 1 (16-bit integers)
  1462.     or 0 to 2^31 - 1 (32-bit integers). The period of this
  1463.     random number generator is 2^31 - 2, irrespective of the
  1464.     integer size.
  1465.  
  1466.     srand can be called at any time to reset the random number
  1467.     generator to a random starting point. The generator is
  1468.     initially seeded with a value of 1.
  1469.  
  1470. SEE ALSO
  1471.     \#random\#, \#srandom\#
  1472.  
  1473. NOTES
  1474.     Although \#random\# is slower, it is a far better random
  1475.     number generator.
  1476.  
  1477.     It seems that BSD UN*X srand returns the previous seed.\end
  1478.  
  1479. screen( capsensitive("random"),
  1480.         capsensitive("srandom"),
  1481.         capsensitive("initstate"),
  1482.         capsensitive("setstate"))
  1483. NAME
  1484.     random, srandom, initstate, setstate - improved random
  1485.     number generator; routines for changing generators
  1486.  
  1487. SYNOPSIS
  1488.     #include <unistd.h>
  1489.  
  1490.     long random(void);
  1491.  
  1492.     void srandom (unsigned int seed);
  1493.  
  1494.     char * initstate (unsigned int seed, char *arg_state, int n);
  1495.  
  1496.     char * setstate (char *arg_state);
  1497.  
  1498. DESCRIPTION
  1499.     random is a good random number generator returning pseudo-
  1500.     random numbers in the range from 0 to 2^31 - 1. The random
  1501.     number generator has a very large period.
  1502.  
  1503.     random/srandom have (almost) the same calling sequence and
  1504.     initialization properties as \#rand\#/\#srand\#. The difference
  1505.     is that \#rand\# produces a much less random sequence, while
  1506.     all the bits generated by random are useable.
  1507.  
  1508.     The initstate routine allows a state array, passed in an
  1509.     argument, to be initialized for future use. The size of the
  1510.     state array (in bytes) is used by initstate to decide how
  1511.     sophisticated a random number generator it should use - the
  1512.     more state, the better the random numbers will be.
  1513.     Good values for the amount of state information are 32, 64,
  1514.     128 and 256 bytes. The seed for the initialization (which
  1515.     specifies a starting point for the random number sequence,
  1516.     and provides for restarting at the same point) is also an
  1517.     argument. initstate returns a pointer to the previous
  1518.     state information array.
  1519.  
  1520.     Once a state array has been initialized, the setstate
  1521.     routine provides for rapid switching between states.
  1522.     setstate returns a pointer to the previous state array;
  1523.     its argument state array is used for further random number
  1524.     generation until the next call to initstate or setstate.
  1525.  
  1526.     Once a state array has been initialized, it may be restarted
  1527.     at a different point either by calling initstate (with the
  1528.     desired seed, the state array, and its size) or by calling
  1529.     both setstate (with the state array) and srandom (with the
  1530.     desired seed). The advantage of calling both setstate and
  1531.     srandom is that the size of the state array does not have
  1532.     to be remembered after it is initialized.
  1533.  
  1534. SEE ALSO
  1535.     \#rand\#, \#srand\#
  1536.  
  1537. NOTES
  1538.     See the source file (random.c) for complete information and
  1539.     comments on the workings of the random number generator.
  1540.  
  1541.     random is slower than \#rand\#.\end
  1542.  
  1543. screen( capsensitive("qsort") )
  1544. NAME
  1545.     qsort - quicker sort
  1546.  
  1547. SYNOPSIS
  1548.     #include <stdlib.h>
  1549.  
  1550.     qsort(void *base, size_t total_elems, size_t elem_size,
  1551.           int (*compare)(const void *one, const void *two));
  1552.  
  1553. DESCRIPTION
  1554.     qsort is an implementation of the quicker-sort algorithm.
  1555.     It sorts a table of data in place.
  1556.       - base points to the element at the base of
  1557.         the table.
  1558.       - total_elems is the number of elements in
  1559.         the table.
  1560.       - elem_size is the size, in bytes, of each element
  1561.         in the table.
  1562.       - compare is the name of the comparison function,
  1563.         which is called with two arguments that point to
  1564.         the elements being compared. As the function must
  1565.         return an integer less than, equal to, or greater
  1566.         than zero, so must the first argument to be considered
  1567.         be less than, equal to, or greater than the second.
  1568.  
  1569. EXAMPLE
  1570.     The following program sorts a simple array:
  1571.         static int intcompare(const void *i, const void *j)
  1572.         {
  1573.           int *one, *two;
  1574.  
  1575.           one = (int *)i;
  1576.           two = (int *)j;
  1577.           return (*one - *two);
  1578.         }
  1579.  
  1580.         void main(void)
  1581.         {
  1582.           int a[10];
  1583.           int i;
  1584.  
  1585.           a[0] = 9;
  1586.           a[1] = 8;
  1587.           a[2] = 7;
  1588.           a[3] = 6;
  1589.           a[4] = 5;
  1590.           a[5] = 4;
  1591.           a[6] = 3;
  1592.           a[7] = 2;
  1593.           a[8] = 1;
  1594.           a[9] = 0;
  1595.  
  1596.           qsort(a, 10, sizeof(int), intcompare);
  1597.           for (i = 0; i < 10; i++)
  1598.             printf(" %d", a[i]);
  1599.           printf("\\n");
  1600.         }
  1601.  
  1602. SEE ALSO
  1603.     \#bsearch\#
  1604.  
  1605. NOTES
  1606.     The comparison function need not compare every byte, so
  1607.     arbitrary data may be contained in the elements in addition
  1608.     to the values being compared.
  1609.  
  1610.     The order in the output of two items which compare as equal
  1611.     is unpredictable.\end
  1612.  
  1613. screen( capsensitive("setbuf"),
  1614.         capsensitive("setvbuf"),
  1615.         capsensitive("setlinebuf"))
  1616. NAME
  1617.     setbuf, setlinebuf, setvbuf - assign buffering to a stream
  1618.  
  1619. SYNOPSIS
  1620.     #include <stdio.h>
  1621.     #include <unistd.h> // Only needed for setlinebuf
  1622.  
  1623.     void setbuf(FILE *stream, char *buf);
  1624.  
  1625.     void setlinebuf(FILE *stream);
  1626.  
  1627.     int setvbuf(FILE *stream, char *buf, int type, size_t size);
  1628.  
  1629. DESCRIPTION
  1630.     setbuf may be used after a stream has been opened but before
  1631.     it is read or written. It causes the array pointed to by buf
  1632.     to be used instead of an automatically allocated buffer.
  1633.     If buf is the NULL pointer input/output will be completely
  1634.     unbuffered.
  1635.  
  1636.     A constant BUFSIZ, defined in <stdio.h>, tells how big an
  1637.     array is needed:
  1638.       char buf[BUFSIZ];
  1639.  
  1640.     setlinebuf may be used after a stream has been opened and
  1641.     after it is read or written. It changes the buffering on
  1642.     stream from block/unbuffered to line buffered.
  1643.  
  1644.     setvbuf may be used after a stream has been opened but before
  1645.     it is read or written. The type parameter determines how
  1646.     stream will be buffered. Legal values for type (defined in
  1647.     <stdio.h>) are:
  1648.  
  1649.       _IOFBF: causes input/output to be fully buffered.
  1650.       _IOLBF: causes output to be line buffered; the buffer
  1651.               will be flushed when a newline is written,
  1652.               the buffer is full, or input is requested.
  1653.       _IONBF: causes input/output to be fully unbuffered.
  1654.  
  1655.     If buf is not the NULL pointer, the array it points to will
  1656.     be used for buffering, instead of an automatically allocated
  1657.     buffer. size specifies the size of the buffer to be used. The
  1658.     constant BUFSIZ in <stdio.h> is suggested as a good buffer
  1659.     size. If input/output is unbuffered, buf and size are ignored.
  1660.  
  1661.     By default, output to a terminal is line buffered and all
  1662.     other input/output is fully buffered.
  1663.  
  1664. SEE ALSO
  1665.     \#fopen\#, \#getc\#, \#putc\#
  1666.  
  1667. RETURN VALUES
  1668.     setvbuf returns a non-zero value if an illegal value for type
  1669.     or size is provided; otherwise, it will return zero.
  1670.  
  1671. NOTES
  1672.     A common source of error is allocating buffer space as an
  1673.     "automatic" variable in a code block, and then failing to
  1674.     close the stream in the same block.
  1675.  
  1676.     setlinebuf is available on BSD UN*X, and not on System V.\end
  1677.  
  1678. screen( capsensitive("sleep"),
  1679.         capsensitive("usleep"))
  1680. NAME
  1681.     sleep, usleep - suspend execution for interval
  1682.  
  1683. SYNOPSIS
  1684.     #include <unistd.h>
  1685.  
  1686.     unsigned sleep(unsigned seconds);
  1687.  
  1688.     void usleep(unsigned long usec); // should be of type unsigned long
  1689.  
  1690. DESCRIPTION
  1691.     The current process is supended from execution for the number
  1692.     of seconds (sleep) or microseconds (usleep) specified by the
  1693.     argument. Sleep returns early if a signal is caught; after the
  1694.     signal handler has returned, sleep will return the "unslept"
  1695.     amount. If no signal was caught, and after the full amount of
  1696.     of time (and possibly somewhat longer) has passed, execution
  1697.     is resumed.
  1698.  
  1699. SEE ALSO
  1700.     \#alarm\#
  1701.     \#Fselect\#, \#Pause\#, \#Psigpause\#, \#Talarm\#
  1702.  
  1703. NOTES
  1704.     On UN*X, usleep is of type unsigned int.
  1705.  
  1706.     Under TOS or MiNT before 0.95, these routines do a busy wait
  1707.     until enough time has passed.\end
  1708.  
  1709. screen( capsensitive("system"))
  1710. NAME
  1711.     system - execute a command, passed a string
  1712.  
  1713. SYNOPSIS
  1714.     #include <unistd.h>
  1715.  
  1716.     int system(const char *cmd);
  1717.  
  1718. DESCRIPTION
  1719.     system executes the command in the string, and waits
  1720.     until it terminates.
  1721.  
  1722.     The first word in the string is the name of the program
  1723.     to be executed; this program is searched in the current
  1724.     directory and on the directories set in the environment
  1725.     variable PATH. The normal extensions ".ttp", ".tos" and 
  1726.     ".prg" are tried when the program is being searched.
  1727.  
  1728.     If the rest of the string contains unquoted '<' or '>'
  1729.     characters, standard input or standard output for the
  1730.     command to be run is redirected to the file with the
  1731.     filename following the '<' or '>'.
  1732.  
  1733.     The remaining part of the string is passed to the program
  1734.     as a command line.
  1735.  
  1736.     This routine is implemented using \#spawnvp\#.
  1737.  
  1738. RETURN VALUES
  1739.     system(NULL) returns 1 as an indication system is supported.
  1740.  
  1741.     When a valid command line is passed, system returns:
  1742.     -1  when out of memory.
  1743.      2  when the redirection of stdin or stdout fails.
  1744.     The return value of the program called when successful.
  1745.  
  1746. SEE ALSO
  1747.     \#spawnvp\#, \#execve\#, \#popen\#
  1748.  
  1749. NOTE
  1750.     On UN*X systems, this starts up the shell /bin/sh as a child
  1751.     process. The shell executes the command passed to system.
  1752.     Thus, on UN*X systems, one can pass a more complicated command
  1753.     line to system, for instance one containing pipes or shell
  1754.     scripts. This may cause some problems when porting UN*X
  1755.     programs to the Atari.\end
  1756.  
  1757. screen(capsensitive("tmpfile"))
  1758. NAME
  1759.     tmpfile - create a temporary file
  1760.  
  1761. SYNOPSIS
  1762.     #include <stdio.h>
  1763.  
  1764.     FILE *tmpfile(void);
  1765.  
  1766. DESCRIPTION
  1767.     tmpfile creates a temporary file using a name generated by
  1768.     \#tmpnam\#, and returns a corresponding FILE pointer. If the file
  1769.     cannot be opened, a NULL pointer is returned. The file will
  1770.     automatically be deleted when the process using it terminates.
  1771.     The file is opened in binary mode for update ("w+b").
  1772.  
  1773. SEE ALSO
  1774.     \#fopen\#, \#mktemp\#, \#tmpnam\#, \#unlink\#
  1775.  
  1776. NOTE
  1777.     When MiNT is active, and the filesystem supports it, the 
  1778.     temporary file will be unlinked while it is open. Otherwise, 
  1779.     the file will be visible to this process and other processes
  1780.     and will be unlinked when the process terminates using a 
  1781.     procedure registered with \#atexit\#. Thus, if MiNT is not
  1782.     active or if the filesystem used does not support unlinking
  1783.     an open file, the temporary file may remain after abnormal
  1784.     program termination.\end
  1785.  
  1786. screen( capsensitive("tmpnam"))
  1787. NAME
  1788.     tmpnam - create a name for a temporary file
  1789.  
  1790. SYNOPSIS
  1791.     #include <stdio.h>
  1792.  
  1793.     char *tmpnam(char *buf);
  1794.  
  1795. DESCRIPTION
  1796.     This function generates a file name that can safely be used
  1797.     for a temporary file.
  1798.  
  1799.     tmpnam always tries to generate a file name in a directory
  1800.     meant for temporary files; it tries to determine such a
  1801.     directory by checking the environment variables TEMP, TMPDIR,
  1802.     TMP and TEMPDIR, successively; if this search fails, the
  1803.     current directory is used.
  1804.  
  1805.     If buf is NULL, tmpnam leaves its result in an internal
  1806.     static area and returns a pointer to that area. The next call
  1807.     to tmpnam will destroy the contents of the area. If buf is
  1808.     not NULL, it is assumed to be the address of an buffer area;
  1809.     tmpnam places its result in that buffer and returns buf.
  1810.  
  1811. SEE ALSO
  1812.     \#creat\#, \#fopen\#, \#mktemp\#, \#tmpfile\#, \#unlink\#
  1813.  
  1814. NOTES
  1815.     The related UN*X function tempnam is currently not available
  1816.     in the mintlibs.
  1817.  
  1818.     This function generates a different file name each time it is
  1819.     called.
  1820.  
  1821.     Files created using this function and either \#fopen\# or \#creat\#
  1822.     are temporarily only in the sense that they reside in a
  1823.     directory intended for temporary use, and their file names
  1824.     are unique. It is the user's responsibility to use \#unlink\# to
  1825.     remove the file when its use is ended.\end
  1826.  
  1827. screen( capsensitive("ttyname"))
  1828. NAME
  1829.     ttyname - find name of a terminal
  1830.  
  1831. SYNOPSIS
  1832.     #include <unistd.h>
  1833.  
  1834.     char *ttyname(int fildes);
  1835.  
  1836. DESCRIPTION
  1837.     ttyname returns a pointer to a string containing the null-
  1838.     terminated path name of the terminal device associated with
  1839.     file descriptor fildes. A NULL pointer is returned if fildes
  1840.     does not describe a terminal device.
  1841.  
  1842. SEE ALSO
  1843.     \#isatty\#
  1844.  
  1845. NOTES
  1846.     If MiNT is not active or a version of MiNT before 0.9 is used,
  1847.     either /dev/aux or /dev/con is returned.
  1848.  
  1849.     If MiNT 0.9 or later is used and no terminal name could be found,
  1850.     /dev/tty is returned.
  1851.  
  1852.     The return value points to static data whose contents is overwritten
  1853.     by each call.\end
  1854.  
  1855.